<?php


namespace Common\Model;

use Think\Model;

class QuestionPraiseModel extends Model
{
    protected $_auto = array(
        array('addtime', 'time', 1, 'function'),
    );

    public function praise_add($uid, $qid)
    {
        $data = compact('uid', 'qid');
        if (!$this->create($data)) {
            $res['status'] = false;
            $res['msg'] = $this->getError();
            return $res;
        } else {
            $newid = $this->add();
            if (!$newid) {
                $res['status'] = false;
                $res['msg'] = '点赞失败';
                return $res;
            } else {
                $res['status'] = true;
                $res['msg'] = '点赞成功';
                return $res;
            }
        }
    }
}